# -*- coding: utf-8 -*-
""" Auteur: Jordan Guerin """
import time
import datetime
import Sheet

#monthsList = ["January","February","March","April","May","June","July","August","September","October","November","December"]
monthsList = ["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"] # En francais
STATUS_WORK_IN_PROGRESS = 0
STATUS_COMPLETED = 1


""" Cette classe représente un événement sur le calendrier. Ces derniers peuvent être
    liés à des CRC (classe Sheet) pour en faire un outil de sprint efficace.
    Responsabilités:
        addLinkToSheet(sheet)
        removeLinkToSheet(sheet)
    Collaborateurs:
        Le nom
        La date
        Le statut (complété, à compléter)
        Les fiches associées
"""
class CalendarEvent(object):
    
    attrDefs = {"name" : str,"dateStart" : long,"dateEnd" : long,"status" : str,"id": int,"version": int,"sheetsLinked" : [Sheet.Sheet]}
    
    def __init__(self,name,dateStart,dateEnd,status,id = None, version = None, sheetsLinked = []):
        self.name = name
        self.id = id
        self.version = version
        self.status = status
        self.dateStart = dateStart
        self.dateEnd = dateEnd
        self.sheetsLinked = sheetsLinked
    
    def addLinkToSheet(self,sheet):
        self.sheetsLinked.append(sheet)
    
    def removeLinkToSheet(self,index):
        self.sheetsLinked.remove(index)

""" Cette classe rerpésente le calendrier. C'est elle qui contient tous les événements.
    Responsabilités:
        addEvent(event)
        removeEvent(index)
    Collaborateurs:
        liste des événements
        La date d'aujourd'hui
"""
class Calendar(object):
    
    attrDefs = {"eventsList" : [CalendarEvent], "date" : [datetime.datetime], "month" : int}
    dependsOn = None
    
    def __init__(self,eventsList):
        self.eventsList = eventsList
        self.date = datetime.datetime.today()
        self.month = self.date.month
    
    def addEvent(self,event):
        self.eventsList.append(event)
        
    def removeEvent(self,index):
        self.eventsList.remove(index)

CalendarEvent.dependsOn = [Calendar]
    
def getEventIndex(name,EventsList):
    increment = 0
    index = -1
    for i in EventsList:
        if i.name == name:
            index = increment
        
        increment = increment + 1
    
    return index

def parseMonthNumber(self,monthStr):
    id = None
        
    increment = 0
    for i in monthsList:
        if i == monthStr:
            id = increment
        increment = increment + 1
        
        if id == None:
            return -1
        else:
            return id
        